/*
** proc_info.c for pud in mrcellophane/libpud
** 
** Made by solomon hykes
** Login   <torgau@gmail.com>
** 
** Started on  Mon May 16 16:17:59 2005 solomon hykes
** Last update Thu May 19 02:20:14 2005 solomon hykes
*/

#include "pud_sys.h"

u_long		pud_pc_get(pud_process *p)
{
  sys_pud_process	*proc = (sys_pud_process *)p;

  if (proc->status != status_stopped)
    return (0);
  return (proc->pc);
}

t_ret		pud_pc_set(pud_process *p, u_long new_pc)
{
  sys_pud_process	*proc = (sys_pud_process *)p;

  if (proc->status != status_stopped)
    return (ret_err);
  /* MACHINE-DEPENDANT */ proc->regs.r_eip = new_pc;
  if (sys_pud_setregs(proc) == ret_err)
    {
      /* MACHINE-DEPENDANT */proc->regs.r_eip = proc->pc;
      return (ret_err);
    }
  return (ret_ok);
}


u_long		pud_stackp_get(pud_process *p)
{
  sys_pud_process	*proc = (sys_pud_process *)p;

  if (proc->status != status_stopped)
    return (0);
  return (proc->stackp);
}

t_ret		pud_stackp_set(pud_process *p, u_long new_stackp)
{
  sys_pud_process	*proc = (sys_pud_process *)p;

  if (proc->status != status_stopped)
    return (ret_err);
  /* MACHINE-DEPENDANT */ proc->regs.r_esp = new_stackp;
  if (sys_pud_setregs(proc) == ret_err)
    {
      /* MACHINE-DEPENDANT */proc->regs.r_esp = proc->stackp;
      return (ret_err);
    }
  return (ret_ok);
}
